package com.example.onion.hxchat.room.dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.onion.hxchat.room.entity.Friend;
import com.example.onion.hxchat.room.entity.User;

import java.util.List;

@Dao
public interface FriendDao
{
    @Insert
    void insertFriend(Friend... student);

    @Delete
    void deleteFriend(Friend student);

    @Update
    void updateFriend(Friend student);


    @Query("DELETE FROM Friend WHERE ownerUserId = :ownerUserIdd AND userId=:uId")
    void deleteByOwner(String ownerUserIdd,String uId);

    @Query("SELECT * FROM Friend WHERE ownerUserId = :id")
    /**
     * 得到所有用户ID是 id的 所有的好友信息
     */
    LiveData<List<Friend>> getAllFriendCur(String id);

    @Query("SELECT * FROM Friend")
    /**
     * 得到所有用户ID是 id的 所有的好友信息
     */
    LiveData<List<Friend>> getAllFriend();

    @Query("SELECT * FROM Friend WHERE ownerUserId = :onwUserId AND userId=:userId")
    /**
     * 查询id用户 ID是id1的好友的 用户信息
     */
    Friend getFriendCur(String onwUserId,String userId);
}